package com.swyc.osschat.Test.LambdaTest.Controller;

import com.swyc.osschat.Test.LambdaTest.IService.TestService;
import com.swyc.osschat.Test.LambdaTest.IService.TestTwoServer;

public class TestConttroller {
    public static void main(String[] args) {
        TestConttroller test = new TestConttroller();
        // 类型声明
//        MathOperation addition = (int a, int b) -> a + b;
        TestService addition = (int a, int b) -> a + b;
        // 不用类型声明
//        MathOperation subtraction = (a, b) -> a - b;
        TestService subtraction = (a, b) -> a - b;
        // 大括号中的返回语句
//        MathOperation multiplication = (int a, int b) -> { return a * b; };
        TestService multiplication = (int a, int b) -> { return a * b; };
        // 没有大括号及返回语句
//        MathOperation division = (int a, int b) -> a / b;
        TestService division = (int a, int b) -> a / b;
        System.out.println("10 + 5 = " + test.operate(10, 5, addition));
        System.out.println("10 - 5 = " + test.operate(10, 5, subtraction));
        System.out.println("10 x 5 = " + test.operate(10, 5, multiplication));
        System.out.println("10 / 5 = " + test.operate(10, 5, division));
        System.out.println("10 / 5 = " + test.operate(10, 5, division));

        // 不用括号
        TestTwoServer greetService1 = message ->
                System.out.println("Hello " + message);

        // 用括号
        TestTwoServer greetService2 = (message) ->
                System.out.println("Hello " + message);

        greetService1.sayMessage("Runoob");
        greetService2.sayMessage("Google");
    }

//    interface MathOperation {
//        int operation(int a, int b);
//    }

    private int operate(int a, int b, TestService mathOperation){
        return mathOperation.operation(a, b);
    }
}
